

package com.idcos.enterprise.portal.web.auto;

// auto generated imports

import com.idcos.enterprise.portal.form.PortalPermissionSaveAuthResForm;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import com.idcos.cloud.biz.common.permisson.OperateAction;
import com.idcos.cloud.web.common.BaseResultVO;
import com.idcos.cloud.web.common.JsonResultUtil;
import com.idcos.enterprise.portal.form.PortalPermissionQueryAuthObjForm;
import com.idcos.enterprise.portal.form.PortalPermissionQueryAuthResForm;
import com.idcos.enterprise.portal.form.PortalPermissionSaveAuthObjForm;
import com.idcos.enterprise.portal.manager.auto.PortalPermissionOperateManager;
import com.idcos.enterprise.portal.manager.auto.PortalPermissionQueryManager;

import java.util.List;

/**
 * web层controller相关的接口自动生成，此文件属于自动生成的，请勿直接修改,具体可以参考codegen工程
 * Generated by <tt>controller-codegen</tt> on 2015-06-09 10:00:37.
 *
 * @author yanlv
 * @version PortalPermissionController.java, v 1.1 2015-06-09 10:00:37 yanlv Exp $
 */

@Controller
@OperateAction("F_PORTAL_PERMISSION")
@RequestMapping(value = "/portal/permission")
@Api(tags = "08.权限授权管理的接口", description = "PortalPermissionController")
public class PortalPermissionController {

    //========== manager ==========

    @Autowired
    private PortalPermissionQueryManager portalPermissionQueryManager;

    @Autowired
    private PortalPermissionOperateManager portalPermissionOperateManager;

    /**
     * 获取授权对象ID
     *
     * @param form
     * @return ${method.returnType}
     */

    @RequestMapping(method = RequestMethod.GET, value = "/queryAuthObjAction")
    @ResponseBody
    @OperateAction("O_PORTAL_PERMISSION_GETOBJ")
    public BaseResultVO queryAuthObj(PortalPermissionQueryAuthObjForm form) {

        return JsonResultUtil.getResult(portalPermissionQueryManager.queryAuthObj(form));

    }

    /**
     * 获取授权资源ID
     *
     * @param form
     * @return ${method.returnType}
     */

    @RequestMapping(method = RequestMethod.GET, value = "/queryAuthResAction")
    @ResponseBody
    @OperateAction("O_PORTAL_PERMISSION_GETRES")
    public BaseResultVO queryAuthRes(PortalPermissionQueryAuthResForm form) {

        return JsonResultUtil.getResult(portalPermissionQueryManager.queryAuthRes(form));

    }

    /**
     * 保存授权对象关系
     *
     * @param form
     * @return ${method.returnType}
     */

    @RequestMapping(method = RequestMethod.POST, value = "/saveAuthObjAction")
    @ResponseBody
    @OperateAction("O_PORTAL_PERMISSION_SAVEOBJ")
    public BaseResultVO saveAuthObj(PortalPermissionSaveAuthObjForm form) {

        return JsonResultUtil.getResult(portalPermissionOperateManager.saveAuthObj(form));

    }

    /**
     * 保存授权资源关系
     *
     * @param permissionInfo
     * @return ${method.returnType}
     */

    @RequestMapping(method = RequestMethod.POST, value = "/saveAuthResAction")
    @ResponseBody
    @OperateAction("O_PORTAL_PERMISSION_SAVERES")
    public BaseResultVO saveAuthRes(@RequestParam("permissionInfo") String permissionInfo) {
        return JsonResultUtil.getResult(portalPermissionOperateManager.saveAuthRes(permissionInfo));
    }

    /**
     * 绑定角色code和权限资源
     *
     * @param tenantId
     * @param roleCode
     * @return ${method.returnType}
     */

    @RequestMapping(method = RequestMethod.POST, value = "/assignByRoleCode")
    @ResponseBody
    @OperateAction("O_PORTAL_PERMISSION_SAVERES")
    public BaseResultVO assignByRoleCode(@RequestParam("tenantId") String tenantId, @RequestParam("roleCode") String roleCode, @RequestBody List<PortalPermissionSaveAuthResForm> perList) {
        return JsonResultUtil.getResult(portalPermissionOperateManager.assignByRoleCode(tenantId, roleCode, perList));
    }

}
